'''
''' UpdateRecord makes use of Web Service to update a record.
'''
''' The table to update a record in.
''' The id used to identify the record that will be updated.
''' Function
''' Nothing, or the new of the inserted record.
Public Overrides Sub UpdateRecord( _
ByVal table As BaseClasses.Data.TableDefinition, _
ByVal recordId As BaseClasses.Data.KeyValue, _
ByVal recValue As BaseClasses.Data.RecordValue, _
ByVal columnsChanged() As Boolean)
Dim ${Primary Key} As Integer
Dim ${First Updatable Field} As String
Dim ${Second Updatable Field} As String
' Get the instance of the data access class.
Dim myTable As ${${Table Name}ClassName}
myTable = ${${Table Name}ClassName}.Instance
Dim col As BaseColumn
For Each col In table.ColumnList
Dim index As Integer = table.ColumnList.IndexOf(col)
If (col.InternalName = _
myTable.${First Updatable Field}Column.InternalName) Then
${First Updatable Field} = _
col.ToDatabaseValue(recValue.ColumnValues(index)).ToString()
ElseIf (col.InternalName = _
myTable.${Second Updatable Field}Column.InternalName) Then
${Second Updatable Field} = _
col.ToDatabaseValue(recValue.ColumnValues(index)).ToString()
ElseIf (col.InternalName = _
myTable.${Primary Key}Column.InternalName) Then
${Primary Key} = CInt(col.ToDatabaseValue( _
recValue.ColumnValues(index)).ToString())
End If
Next
' Instantiate the object that will communicate with a web service.
' Replace MyWebServiceForTableAccess with the external Web Service name
Dim webService As New localhost.MyWebServiceForTableAccess
webService.Credentials = System.Net.CredentialCache.DefaultCredentials
' Call the web service's "UpdateRecord" function.
webService.Update${${Table Name}RecordClassName}(${Primary Key}, _
${First Updatable Field}, ${Second Updatable Field})
End Sub
|